Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce config map watcher for feature flags #2637

Merged

Conversation

adshmh
Copy link
Contributor

@adshmh adshmh commented May 17, 2020

Changes

Taskrun reconciler now uses a configmap watcher for feature-flags
configmap to remove the need for an extra Kubernetes API call to get the
configmap's value every time a pod is being created. Fixes #2117.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Release Notes

@tekton-robot tekton-robot requested review from imjasonh and a user May 17, 2020 20:30
@tekton-robot tekton-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 17, 2020
@tekton-robot
Copy link
Collaborator

Hi @adshmh. Thanks for your PR.

I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot
Copy link
Collaborator

This PR cannot be merged: expecting exactly one kind/ label

Available kind/ labels are:

kind/bug: Categorizes issue or PR as related to a bug.
kind/flake: Categorizes issue or PR as related to a flakey test
kind/cleanup: Categorizes issue or PR as related to cleaning up code, process, or technical debt.
kind/design: Categorizes issue or PR as related to design.
kind/documentation: Categorizes issue or PR as related to documentation.
kind/feature: Categorizes issue or PR as related to a new feature.
kind/misc: Categorizes issue or PR as a miscellaneuous one.

2 similar comments
@tekton-robot
Copy link
Collaborator

This PR cannot be merged: expecting exactly one kind/ label

Available kind/ labels are:

kind/bug: Categorizes issue or PR as related to a bug.
kind/flake: Categorizes issue or PR as related to a flakey test
kind/cleanup: Categorizes issue or PR as related to cleaning up code, process, or technical debt.
kind/design: Categorizes issue or PR as related to design.
kind/documentation: Categorizes issue or PR as related to documentation.
kind/feature: Categorizes issue or PR as related to a new feature.
kind/misc: Categorizes issue or PR as a miscellaneuous one.

@tekton-robot
Copy link
Collaborator

This PR cannot be merged: expecting exactly one kind/ label

Available kind/ labels are:

kind/bug: Categorizes issue or PR as related to a bug.
kind/flake: Categorizes issue or PR as related to a flakey test
kind/cleanup: Categorizes issue or PR as related to cleaning up code, process, or technical debt.
kind/design: Categorizes issue or PR as related to design.
kind/documentation: Categorizes issue or PR as related to documentation.
kind/feature: Categorizes issue or PR as related to a new feature.
kind/misc: Categorizes issue or PR as a miscellaneuous one.

@vdemeester
Copy link
Member

/ok-to-test
/kind feature
/cc @sbwsg

@tekton-robot tekton-robot added kind/feature Categorizes issue or PR as related to a new feature. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 18, 2020
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/pod.go Do not exist 82.8%
pkg/reconciler/taskrun/controller.go 96.2% 96.4% 0.3
pkg/reconciler/taskrun/taskrun.go 75.2% 75.3% 0.1

@adshmh adshmh force-pushed the 2117-config-map-watcher-for-feature-flags branch from 210c5eb to 19e2cf0 Compare May 18, 2020 11:00
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/pod.go Do not exist 82.8%
pkg/reconciler/taskrun/controller.go 96.2% 96.4% 0.3
pkg/reconciler/taskrun/taskrun.go 75.2% 75.3% 0.1

@adshmh adshmh force-pushed the 2117-config-map-watcher-for-feature-flags branch from 19e2cf0 to dd6ff21 Compare May 18, 2020 12:04
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/pod.go Do not exist 82.8%
pkg/reconciler/taskrun/controller.go 96.2% 96.4% 0.3
pkg/reconciler/taskrun/taskrun.go 75.2% 75.3% 0.1

@vdemeester vdemeester added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/feature Categorizes issue or PR as related to a new feature. labels May 18, 2020
@tekton-robot
Copy link
Collaborator

This PR cannot be merged: expecting exactly one kind/ label

Available kind/ labels are:

kind/bug: Categorizes issue or PR as related to a bug.
kind/flake: Categorizes issue or PR as related to a flakey test
kind/cleanup: Categorizes issue or PR as related to cleaning up code, process, or technical debt.
kind/design: Categorizes issue or PR as related to design.
kind/documentation: Categorizes issue or PR as related to documentation.
kind/feature: Categorizes issue or PR as related to a new feature.
kind/misc: Categorizes issue or PR as a miscellaneuous one.

Copy link
Member

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for working on this, I've been wondering why we used the configStore for pipelineruns and not for taskruns too.
My main questions on this is whether we really need the extra module, or if we could just use the existing one and add extra flags to it?

The other question I have is about the existing config store. The testing methods for the pipelinerun controller do not support having configmaps as test data to seed. I think this probably means that we had less coverage there. Would it make sense to add the same feature there? (possibly in a different PR)

@@ -0,0 +1,78 @@
/*
Copyright 2019 The Tekton Authors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: this should probably be 2020

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. Fixed.

The other question I have is about the existing config store. The testing methods for the pipelinerun controller do not support having configmaps as test data to seed. I think this probably means that we had less coverage there. Would it make sense to add the same feature there? (possibly in a different PR)

Sure. I will review the pipelinerun controller code and submit a PR to cover this.

@@ -0,0 +1,99 @@
/*
Copyright 2019 The Tekton Authors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. Fixed.

@@ -0,0 +1,22 @@
# Copyright 2019 The Tekton Authors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. Fixed.

@@ -0,0 +1,26 @@
# Copyright 2019 The Tekton Authors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. Fixed.

@@ -0,0 +1,22 @@
# Copyright 2019 The Tekton Authors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. Fixed.

return false
}
return true
func ShouldOverrideHomeEnv(ctx context.Context) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :)

Clients: c,
}, cancel
}, cancel, stopCh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already return a cancel function to tests, so it doesn't feel ok to pass them an extra channel to stop.

I wonder if it would be possible to change SetupFakeContext to handle the configMapWatcher instead, but at least we should be able to return something like:

, func() {
   close(stopCh)
   cancel()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. Fixed. I will take a look and submit a PR if there is a way to avoid dealing with the channel altogether, i.e. letting SetupFakeContext handle it.

@@ -479,6 +519,184 @@ func TestReconcile_ExplicitDefaultSA(t *testing.T) {
}
}

func TestReconcile_FeatureFlags(t *testing.T) {
taskWithEnvVar := tb.Task("test-task-with-env-var",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if you could add a comment that describes what the test aims to verify!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. Fixed.

return &Config{
Defaults: defaults,
Defaults: defaults,
FeatureFlags: featureFlags,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify why we need FeatureFlags to be separated from Defaults?
AFAIU feature flags are a special type of defaults, that take a boolean value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for working on this, I've been wondering why we used the configStore for pipelineruns and not for taskruns too.
My main questions on this is whether we really need the extra module, or if we could just use the existing one and add extra flags to it?

Thank you for the detailed review. Please let me know if the following sounds correct. I'd be happy to update the PR if needed to merge the two sets of options.

I have implemented the draft this way mainly because the feature-flags and config-defaults are different config maps. Modules using the config store are only minimally affected by this: they use config store the same way, i.e. by passing the context, just specify the flags under FeatureFlags "option group" as Defaults and FeatureFlags are both structs under the same config module.

If combining the two sets is preferred, please let me know and I will update the PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to like having it seperate 🤔
/cc @sbwsg

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, feature-flags is already a separate ConfigMap. If we wanted to merge it with config-defaults then I'd prefer that be a discussion/PR unto itself rather than mix it in with a behavioral change such as this. @afrittoli if you prefer to go that route do you want to pursue it at an upcoming WG?

@adshmh adshmh force-pushed the 2117-config-map-watcher-for-feature-flags branch from dd6ff21 to d0fa286 Compare May 22, 2020 15:54
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/pod.go Do not exist 82.8%
pkg/reconciler/taskrun/controller.go 96.2% 96.4% 0.3
pkg/reconciler/taskrun/taskrun.go 75.2% 75.3% 0.1

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

return &Config{
Defaults: defaults,
Defaults: defaults,
FeatureFlags: featureFlags,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to like having it seperate 🤔
/cc @sbwsg

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 2, 2020
Copy link
Member

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification.
My intention was not to merge the configmaps necessarily, I was only trying to understand if we had to duplicate the logic that manages the configmaps.

It's fine for me to go ahead as it is, we can still factor things up later if possible.

@ghost
Copy link

ghost commented Jun 2, 2020

I was only trying to understand if we had to duplicate the logic that manages the configmaps.

Oh I see, apologies! This makes perfect sense to me. Agree on it being a possible improvement!

@@ -0,0 +1,40 @@
/*
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did these vendor changes come from? I see vendor/modules.txt updated but I have to confess I don't really understand how that plays with go.mod / go.sum. Did you manually update that file? Or was it somehow automatically updated?

Copy link
Contributor Author

@adshmh adshmh Jun 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. The changes in vendor/modules.txt were made by the hack/update-deps.sh script.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand why vendor/modules.txt would be updated but not go.mod or go.sum but 🤷.

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbwsg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 4, 2020
@jlpettersson
Copy link
Member

There are two new feature-flags added to this configMap in #2158 and #2630

Feature flags configuration is now tracked by the config store. This
allows watching for the corresponding config map changes, removing the
need to call kubernetes API to get the feature flags config map every
time a pod is created.

Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
Taskrun reconciler now uses a configmap watcher for `feature-flags`
configmap to remove the need for an extra Kubernetes API call to get the
configmap's value every time a pod is being created.

Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
@adshmh adshmh force-pushed the 2117-config-map-watcher-for-feature-flags branch from d0fa286 to 64da2b5 Compare June 6, 2020 17:09
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Jun 6, 2020
@adshmh
Copy link
Contributor Author

adshmh commented Jun 6, 2020

There are two new feature-flags added to this configMap in #2158 and #2630

Thank you for the reminder. Fixed.

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/pod/pod.go Do not exist 84.5%
pkg/reconciler/pipelinerun/affinity_assistant.go 91.8% 91.5% -0.3
pkg/reconciler/taskrun/controller.go 96.2% 96.4% 0.3
pkg/reconciler/taskrun/taskrun.go 76.0% 76.1% 0.1

@adshmh
Copy link
Contributor Author

adshmh commented Jun 6, 2020

/retest

@vdemeester
Copy link
Member

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce ConfigMap watcher for feature-flags
5 participants